import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { AtImagePicker } from 'taro-ui';
import { inject, observer } from "@tarojs/mobx-rn";
import { View, Input, Form, Button } from "@tarojs/components-rn";
import PageFooterInfo from "../../components/PageFooterInfo";
import { getRuntime } from "../../utils/common";
import page2_declareStyleSheet from "./page2_declare_styles";
var _styleSheet = page2_declareStyleSheet;
let Page1 = class Page1 extends Component {
  constructor(props) {
    super(props);
    this.state = {
      companyName: '',
      businessScopeArr: [],
      businessScope: '',
      certificateIMGArr: [],
      certificateIMG: '',
      openAnAccountIMG: '',
      iDcardImg: '',
      institutionalFrameworkIMG: '',
      registerImg: '',
      contactsName: '',
      phoneNumnber: '',
      emailAddress: '',
      address: '',
      type: 0,
      loading: false,
      disabled: false,
      submitText: '立即预约办理'
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '公司报税' });
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  changePicker() {}
  onChangeImg(type, e) {
    // console.log(e)
    getRuntime().uploadFile(e, res => {
      // console.log(res)
      this.setState({
        certificateIMGArr: e,
        certificateIMG: res.join(',')
      });
    });
  }
  formSubmit(e) {
    let { certificateIMG, type } = this.state;
    let { companyName, businessScope, contactsName, phoneNumnber, emailAddress, address } = e.detail.value;
    let { FinancialCenterStore } = this.props.stores;
    if (!companyName) {
      getRuntime().showToast('公司名称不能为空~');
      return false;
    }
    if (!contactsName) {
      getRuntime().showToast('联系人姓名不能为空~');
      return false;
    }
    if (!phoneNumnber) {
      getRuntime().showToast('联系人电话不能为空~');
      return false;
    }
    this.setState({
      loading: true,
      disabled: true,
      submitText: '数据提交中...'
    });
    FinancialCenterStore.saveCompanyTaxReturn({
      form: {
        type, companyName, businessScope, certificateIMG, contactsName, phoneNumnber, emailAddress, address
      },
      callback: () => {
        this.setState({
          loading: false,
          disabled: false,
          submitText: '立即预约办理'
        });
        getRuntime().navigateTo('/pages/business/business_success');
      }
    });
  }
  render() {
    let { loading, disabled, submitText, certificateIMGArr } = this.state;
    return <View style={_styleSheet["from-wrap"]}>
        <Form onSubmit={this.formSubmit.bind(this)}>
          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>公司名称</View>
              <Input name="companyName" placeholderClass="placeholder_class" placeholder="请填写公司名称" style={_styleSheet["from-input"]} />
            </View>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>经营范围</View>
             
              <Input name="businessScope" placeholderClass="placeholder_class" placeholder="请填写经营范围" style={_styleSheet["from-input"]} />
            </View>
            <View style={[_styleSheet["input-group"], _styleSheet["input-upload"]]}>
              <View style={_styleSheet["input-name"]}>上传营业执照</View>
              <AtImagePicker name="certificateIMG" length={4} count={1} showAddBtn={true} files={certificateIMGArr} onChange={this.onChangeImg.bind(this, 'certificateIMG')} />
            </View>
          </View>

          <View style={[_styleSheet["item-group"], _styleSheet["pt0"], _styleSheet["pb0"]]}>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系人</View>
              <Input name="contactsName" placeholderClass="placeholder_class" placeholder="请填写联系人" style={_styleSheet["from-input"]} />
            </View>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系电话</View>
              <Input type={"number"} maxLength={11} name="phoneNumnber" placeholderClass="placeholder_class" placeholder="请填写联系电话" style={_styleSheet["from-input"]} />
            </View>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系邮箱</View>
              <Input name="emailAddress" placeholderClass="placeholder_class" placeholder="请填写联系邮箱" style={_styleSheet["from-input"]} />
            </View>
            <View style={_styleSheet["input-group"]}>
              <View style={_styleSheet["input-name"]}>联系地址</View>
              <Input name="address" placeholderClass="placeholder_class" placeholder="请填写联系地址" style={_styleSheet["from-input"]} />
            </View>
          </View>
          <Button formType="submit" disabled={disabled} loading={loading} style={_styleSheet["page-submit"]}>{submitText}</Button>
        </Form>

        <PageFooterInfo />
      </View>;
  }
};
Page1 = tslib_1.__decorate([inject("stores"), observer], Page1);
export default Page1;